var timestampplan =631123200000/1000;
$().ready(function() {
	validateRule();

	$("#preTask").change(function () {
        $("#event").val($("#preTask").val())
    })
});

$.validator.setDefaults({
	submitHandler : function() {
		save();
	}
});
function save() {
    var plantime = $('#plantime').val();
    timestampplan  = 631123200000/1000;
    if(plantime !=null && plantime !="") {
        plantime = plantime.substring(0,19);
        timestampplan = (new Date(plantime).getTime())/1000;
    }else{
        alert("请填写计划完成时间")
        return;
    }
    if($('#event').val() ==null && $('#event').val() =="") {
        alert("请填写任务名称")
        return;
    }
	$.ajax({
		cache : true,
		type : "POST",
		url : "/server/importantexecute/save",
		data : $('#signupForm').serialize(),// 你的formid
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			name : {
				required : true
			}
		},
		messages : {
			name : {
				required : icon + "请输入姓名"
			}
		}
	})
}